package io.renren.modules.draw_money_log.controller;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.draw_money_log.entity.V9DrawMoneyLogEntity;
import io.renren.modules.draw_money_log.entity.params.V9drawMoneyLogParams;
import io.renren.modules.draw_money_log.service.V9DrawMoneyLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 佣金转入余额
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-09-19 18:56:40
 */
@RestController
@RequestMapping("draw_money_log/v9drawmoneylog")
public class V9DrawMoneyLogController {
    @Autowired
    private V9DrawMoneyLogService v9DrawMoneyLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("draw_money_log:v9drawmoneylog:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = v9DrawMoneyLogService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{dmlId}")
    @RequiresPermissions("draw_money_log:v9drawmoneylog:info")
    public R info(@PathVariable("dmlId") Integer dmlId){
		V9DrawMoneyLogEntity v9DrawMoneyLog = v9DrawMoneyLogService.getById(dmlId);

        return R.ok().put("v9DrawMoneyLog", v9DrawMoneyLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("draw_money_log:v9drawmoneylog:save")
    public R save(@RequestBody V9DrawMoneyLogEntity v9DrawMoneyLog){

        if (v9DrawMoneyLog.getDmlAudittimeStr()!=null){
            v9DrawMoneyLog.setDmlAudittimeStr(v9DrawMoneyLog.getDmlAudittimeStr());
            v9DrawMoneyLogService.save(v9DrawMoneyLog);
        }
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("draw_money_log:v9drawmoneylog:update")
    public R update(@RequestBody V9DrawMoneyLogEntity v9DrawMoneyLog){
		v9DrawMoneyLogService.updateById(v9DrawMoneyLog);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("draw_money_log:v9drawmoneylog:delete")
    public R delete(@RequestBody Integer[] dmlIds){
		v9DrawMoneyLogService.removeByIds(Arrays.asList(dmlIds));

        return R.ok();
    }
    /*
     * 审核
     * */
    @RequestMapping("/pass")
    public R pass(@RequestBody V9drawMoneyLogParams params){
        return v9DrawMoneyLogService.pass(params);
    }

}
